home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
graphics
/
sin.frm
< prev
next >
Wrap
Text File
|
1993-05-16
|
2KB
|
103 lines
VERSION 2.00
Begin Form Form1
BackColor = &H0000FF00&
Caption = "Form1"
ClientHeight = 1770
ClientLeft = 1320
ClientTop = 1860
ClientWidth = 4425
Height = 2175
Left = 1260
LinkTopic = "Form1"
ScaleHeight = 1770
ScaleWidth = 4425
Top = 1515
Width = 4545
End
Dim PI As Double
Sub Form_Activate ()
Const GRANULARITY = .03
Const LINE_HEIGHT = .05
Const LINE_WIDTH = .25
Dim i As Double
Dim TwicePI As Double, PiOver2 As Double
Dim p1 As Double, p2 As Double
TwicePI = PI * 2#
PiOver2 = PI / 2#
'Establish a coordinate system and draw axes.
form1.Scale (-TwicePI - .1, 1.1)-(TwicePI + .1, -1.1)
Line (-TwicePI, 0)-(TwicePI, 0)
Line (0, 1)-(0, -1)
'Draw marks on the horizontal axis.
For i = -TwicePI To TwicePI Step PI / 4#
Line (i, LINE_HEIGHT)-(i, -LINE_HEIGHT)
Next i
currenty = -.1
currentx = -TwicePI
Print "-2pi"
currenty = .2
currentx = -1.6 * PI
Print "-1.5pi"
currenty = .2
currentx = -.6 * PI
Print "-.5pi"
currenty = -.1
currentx = -1.1 * PI
Print "-pi"
currenty = .2
currentx = .4 * PI
Print ".5pi"
currenty = -.1
currentx = .93 * PI
Print "pi"
currenty = -.1
currentx = 1.4 * PI
Print "1.5pi"
currenty = .2
currentx = TwicePI - .4
Print "2pi"
'Draw marks and labels on the vertical axis.
For i = 1# To -1# Step -.25
Line (-LINE_WIDTH, i)-(LINE_WIDTH, i)
Next i
For i = 1# To .25 Step -.25
currentx = -.9
currenty = i + .05
Print Str$(i)
Next i
For i = -.25 To -1# Step -.25
currentx = .3
currenty = i + .05
Print Str$(i)
Next i
form1.Caption = "A graph of the sin from -2 PI to 2 PI."
p1 = Sin(-TwicePI)
For i = -TwicePI + GRANULARITY To TwicePI Step GRANULARITY
p2 = Sin(i)
Line (i, p1)-(i, p2)
p1 = p2
Next i
End Sub
Sub Form_Load ()
PI = Atn(1#) * 4
drawwidth = 2
form1.Width = .9 * screen.Width
form1.Height = .6 * screen.Height
form1.Top = .2 * screen.Height
form1.Left = .05 * screen.Width
End Sub